﻿
using System;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EnterpriseServices.Service
{
    public partial class MembershipProxy : IMembershipManager
    {
        #region IMembershipManager Members

        /// <summary>
        /// Creates the user.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <param name="email">The email.</param>
        /// <param name="passwordQuestion">The password question.</param>
        /// <param name="passwordAnswer">The password answer.</param>
        /// <param name="isApproved">if set to <c>true</c> [is approved].</param>
        public void CreateUser(string userName, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved)
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            proxy.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, isApproved);
        }

        public void CreateUser(string userName)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Deletes the user.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="deleteAllRelatedData">if set to <c>true</c> [delete all related data].</param>
        /// <returns></returns>
        public bool DeleteUser(string userName, bool deleteAllRelatedData)
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            return proxy.DeleteUser(userName, deleteAllRelatedData);
        }

        /// <summary>
        /// Deletes all users.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="deleteAllRelatedData">if set to <c>true</c> [delete all related data].</param>
        public void DeleteAllUsers(bool deleteAllRelatedData)
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            proxy.DeleteAllUsers(deleteAllRelatedData);
        }

        /// <summary>
        /// Gets the user name by email.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="email">The email.</param>
        /// <returns></returns>
        public string GetUserNameByEmail(string email)
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            return proxy.GetUserNameByEmail(email);
        }

        /// <summary>
        /// Gets the number of users online.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public int GetNumberOfUsersOnline()
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            return proxy.GetNumberOfUsersOnline();
        }

        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="email">The email.</param>
        /// <param name="oldAnswer">The old answer.</param>
        /// <param name="newQuestion">The new question.</param>
        /// <param name="newAnswer">The new answer.</param>
        /// <param name="isApproved">if set to <c>true</c> [is approved].</param>
        /// <param name="isLockedOut">if set to <c>true</c> [is locked out].</param>
        public void UpdateUser(string userName, string email, string oldAnswer, string newQuestion, string newAnswer, bool isApproved, bool isLockedOut)
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            proxy.UpdateUser(userName, email, oldAnswer, newQuestion, newAnswer, isApproved, isLockedOut);
        }

        /// <summary>
        /// Users the is online time window.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public int UserIsOnlineTimeWindow()
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            return proxy.UserIsOnlineTimeWindow();
        }

        /// <summary>
        /// Gets all users.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <returns></returns>
        public string[] GetAllUsers()
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            return proxy.GetAllUsers();
        }

        /// <summary>
        /// Gets the user info.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns>UserInfo object</returns>
        public UserInfo GetUserInfo(string userName)
        {
            IMembershipManager proxy = new ChannelFactory<IMembershipManager>().CreateChannel();
            return proxy.GetUserInfo(userName);
        }

        #endregion

    }
}
